{include file="public/toper" /}
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">运营中心</a>
        <a href="">主题管理/{$list.name}</a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">&#xe666;</i></a>
</div>
<form action="" method="post" class="layui-form" id="forms">
    <div class="layui-form-item">
        <label class="layui-form-label">
            <span class="x-red">*</span>主题ID
        </label>
        <div class="layui-input-inline">
            <input type="text" value="{$list.theme_id}" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">
            <span class="x-red">*</span>主题名称
        </label>
        <div class="layui-input-inline">
            <input type="text" value="{$list.name}" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">
            <span class="x-red">*</span>焦点图图片
        </label>
        <div class="layui-input-inline layui-upload" id="upload-thumb">
            <div class="layui-upload-list">
                <img src="{$list.img}" class="layui-upload-list" id="demo" width="100" height="100">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">
            <span class="x-red">*</span>状态
        </label>
        <div class="layui-input-block">
            <input type="text" value="{if condition = "$list.state eq 0 "}未发布{elseif condition = "$list.state eq 1 "/}发布中{elseif condition = "$list.state eq 2 "/}已停止{/if}" class="layui-input" disabled>
        </div>
    </div>
</form>
<div class="x-body">
    <xblock class="demoTable">
        <span id="theme" class="layui-icon" style="color:#01AAED;text-align: right">选择商品</span>
    </xblock>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="image">
    <img src="{{d.img}}" class="thumb" thumb="{{ d.img }}"/>
</script>
<script type="text/html" id="sort">
    <input style="width: 100%" type="text" class="menu-sort j-ajax-input" name="sort" onkeyup="value=value.replace(/[^\d]/g,'')" value="{{d.sort}}" data-value="{{d.sort}}" data-href="{:url('sort')}?table=theme_goods&ids={{d.id}}">
</script>
<script type="text/html" id="action">
    <button class="layui-btn-danger layui-btn layui-btn-xs del_btn" id="{{d.id}}" lay-event="del"><i class="layui-icon">&#xe640;</i>删除</button>
</script>
<script>
    layui.use(['table','util'], function(){
        var table = layui.table, $ = layui.jquery;
        var layer = layui.layer;
        var loading = layer.load(1, {shade: [0.1,'#fff'] });
        var tableIn = table.render({
            method: 'post',
            elem: '#test'
            ,url: "{:url('Theme/index2')}"
            ,id:'test'
            ,cols: [[
                {field:'theme_id', width:80, title: '序号',align: 'center',type:'numbers'}
                ,{field:'name',width: 250,title: '商品名称', align: 'center'}
                ,{width:100, title: '缩略图',align: 'center',toolbar:'#image'}
                ,{field:'label',width: 150,title: '标签', align: 'center'}
                ,{field:'sname',width: 150,title: '所属门店', align: 'center'}
                ,{field:'large',width: 100,title: '销售价', align: 'center'}
                ,{width:80,title: '排序',align: 'center',toolbar:'#sort'}
                ,{width: 180,title: '操作', align: 'center', toolbar: '#action'}
            ]]
            ,page: true
            ,limit: 30
            ,limits:[30,60,90,120,150,180,210,240,270,300]
            , where: {id:{$list['theme_id']}}
        });
        layer.close(loading);

        table.on('tool(test)', function(obj) {
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('您确定要删除【'+data.name+'】吗？',{btnAlign: 'c'}, function(index){
                    var loading = layer.load(1, {shade: [0.1,'#fff'] });
                    $.post("{:url('Theme/del2')}",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code==200){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload(test)
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });

        $("#theme").click(function(){
            layer.open({
                type: 2,
                title: '选择用户',
                area: ['900px', '650px'],
                fixed: false, //不固定
                maxmin: true,
                content: "{:url('Goods/themegoods')}?id={$list.theme_id}"
            });
        });
    });
</script>
{include file="public/footer"/}